<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">
    
    <title>Dynamic Table</title>
    
    <!--dynamic table-->
    <link href="/public/js/advanced-datatable/css/demo_page.css" rel="stylesheet" />
    <link href="/public/js/advanced-datatable/css/demo_table.css" rel="stylesheet" />
    <link rel="stylesheet" href="/public/js/data-tables/DT_bootstrap.css" />
    <?php $this->load->view('library/header');?>
</head>

<body class="sticky-header">

<section>
    
    <?php $this->load->view('library/left');?>
    
    <!-- main content start-->
    <div class="main-content" >
        
        <?php $this->load->view('library/top');?>
        
        <!-- page heading start-->
        <div class="page-heading">
            <h3>站点列表</h3>
        </div>
        <!-- page heading end-->
        
        <!--body wrapper start-->
        <div class="wrapper">
            <div class="row">
                <div class="col-sm-12">
                    <?php $this->load->view('library/search');?>
                    <section class="panel">
                        <div class="panel-body">
                            
                            <div class="adv-table">
                                <table  class="display table table-bordered table-striped" id="dynamic-table">
                                    <thead>
                                    <tr>
                                        <th width="3%">#</th>
                                        <th width="10%">站点名称</th>
                                        <th width="6%" class="hidden-phone">产品前缀</th>
                                        <th width="6%" class="hidden-phone">货号前缀</th>
                                        <th width="5%" class="hidden-phone">是否关闭</th>
                                        <th width="5%" class="hidden-phone">排序</th>
                                        <th width="8%" class="hidden-phone">添加时间</th>
                                        <th width="5%" class="hidden-phone">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php foreach ($web_list as $item): ?>
                                        <tr class="gradeX">
                                            <td><?php echo $item['web_id'];?></td>
                                            <td><?php echo $item['web_name'];?></td>
                                            <td class="center hidden-phone"><?php echo $item['title'];?></td>
                                            <td class="center hidden-phone"><?php echo $item['ab_name'];?></td>
                                            <td class="center hidden-phone"><?php echo $item['is_delete'] ? '是' : '否';?></td>
                                            <td class="center hidden-phone"><?php echo $item['sort_num'];?></td>
                                            <td class="hidden-phone"><?php echo $item['add_time'] ? date('Y-m-d H:s:i', $item['add_time']) : 0;?></td>
                                            <td class="hidden-phone">
                                                <a class="btn btn-xs btn-info" href="<?php echo base_url('siteweb/set/web_id/'. $item['web_id']);?>">编辑</a>
                                                <a class="btn btn-xs btn-info a-ajax" href="<?php echo base_url('UeeshopApi/cate/web_id/'. $item['web_id']);?>">更新分类</a>
                                                <?php if($item['is_delete'] == 0): ?>
                                                <a class="btn btn-xs btn-info" onclick="edit_status(<?= $item['web_id'] ?>,'del')" > 关闭 </a >
                                                <?php else: ?>
                                                <a class="btn btn-xs btn-info" onclick="edit_status(<?= $item['web_id'] ?>,'open')" > 开启 </a >
                                                <?php endif; ?>
                                            </td>
                                        </tr>
                                    <?php endforeach;?>
                                    </tbody>
                                </table>
                            </div>
                            <div class="row-fluid">
                                <div class="span6">
                                    <div class="dataTables_paginate paging_bootstrap pagination">
                                        <ul>
                                            <?php echo $pages;?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </div>
        <!--body wrapper end-->
        
        <!--footer section start-->
        <footer>
            2014 &copy; AdminEx by
        </footer>
        <!--footer section end-->
    
    
    </div>
    <!-- main content end-->
</section>

<?php $this->load->view('library/footer');?>

<!--dynamic table
<script type="text/javascript" language="javascript" src="/public/js/advanced-datatable/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="/public/js/data-tables/DT_bootstrap.js"></script>-->
<!--dynamic table initialization
<script src="/public/js/dynamic_table_init.js"></script>-->

<!--common scripts for all pages-->
<script src="/public/js/scripts.js"></script>
<script type="text/javascript">
    $('.a-ajax').click(function () {

        var url = $(this).attr('href');
        swal({
            title: '确定要更新吗?',
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Yes, delete it!'
        }).then(function (result) {
            if (result.value) {
                $.get(url, {is_ajax: 1}, function (data) {
                    swal({
                        title: data.info,
                        text: '2秒后关闭',
                        type: data.status,
                        allowOutsideClick: false,
                        timer: data.stop ? data.stop : 1500,
                        showConfirmButton: false
                    }).then(function(isConfirm) {
                        location.reload();
                    });

                }, 'json');
            }
        })


        return false;
    });

    var url = "<?=$sync_url?>";

    function edit_status(id, act) {
      $.post(url, {'id': id, 'act': act}, function (data) {
        if (data.code === 200) {
          layer.msg(data.msg, {icon: 6, time: 1000}, function () {
            // $ ("#" + id).hide ()
            location.reload()
          })
        } else {
          layer.msg('失败', {icon: 5, time: 1000})
        }
      })

    }

</script>
</body>
</html>
